package com.example.houduan.service;

import com.example.houduan.domain.F_sb;
import com.example.houduan.domain.F_sbExample;
import java.util.UUID;
import com.example.houduan.mapper.F_sbMapper;
import com.example.houduan.resp.CommonResp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class Lfdjservice {
    @Autowired
    private F_sbMapper f_sbMapper;
    public CommonResp add(F_sb f_sb) {
        CommonResp commonResp =new CommonResp();
        f_sb.setFid(getUUID());
        int insert= f_sbMapper.insert(f_sb);
        if (insert==0)
        {
            commonResp.setContent(false);
            return commonResp;
        }else{
            commonResp.setContent(true);
            return commonResp;
        }
    }
    public static String getUUID(){
        String id = UUID.randomUUID().toString();
        String uid = id.replaceAll("-", "");
        return uid;
    }
    public CommonResp listall(String uid) {
        CommonResp commonResp=new CommonResp();
        F_sbExample f_sbExample=new F_sbExample();
        F_sbExample.Criteria criteria=f_sbExample.createCriteria();
        criteria.andUidEqualTo(uid);
        List<F_sb> f_sbs=f_sbMapper.selectByExample(f_sbExample);
        commonResp.setContent(f_sbs);
        return commonResp;
    }
}
